/**
 * 入库明细表js
 */

$(function () {
	initialPage();
	getGrid();
});

function initialPage() {
	$(window).resize(function() {
		$('#dataGridForOutBound').bootstrapTable('resetView', {height: $(window).height()-56});
	});
}

function getGrid() {
    $('#dataGridForOutBound').bootstrapTableEx({
        url: '../../../inboundDetails/list?_' + $.now(),
        height: $(window).height()-56,
        clickToSelect: true,
        queryParams: function(params){
            params.name = vm.keyword;
            params.inBoundId = vm.inBoundId;
            return params;
        },
        columns: [
            {radio : true},
            {
                field: "num",
                title : '序号',
                align: "center",
                width: 40,
                formatter: function (value, row, index) {
                    //获取每页显示的数量
                    var pageSize=$('#dataGridForOutBound').bootstrapTable('getOptions').pageSize;
                    //获取当前是第几页
                    var pageNumber=$('#dataGridForOutBound').bootstrapTable('getOptions').pageNumber;
                    //返回序号，注意index是从0开始的，所以要加上1
                    return pageSize * (pageNumber - 1) + index + 1;
                }
            },
            {field : "name", title : "商品名称", width : "100px"},
            {field : "specification", title : "商品规格", width : "100px"},
            {field : "unit", title : "商品单位", width : "100px"},
            {field : "manufacturer", title : "生产厂家", width : "100px"},
            {field : "deptName", title : "库房", width : "100px"},
            {field : "itemName", title : "项目", width : "100px"},
            {field : "quantity", title : "当前库存", width : "100px"},
            {field : "unitPrice", title : "进货单价", width : "100px",
                formatter : function (value, row, index) {
                    return value.toFixed(2);
                }
            },
            {field : "totalPrice", title : "进货总价", width : "100px",
                formatter : function (value, row, index) {
                    return value.toFixed(2);
                }
            }
        ]
    })
}

var vm = new Vue({
	el:'#dpLTE',
	data: {
		keyword: null,
        inBoundId: null,
	},
	methods : {
		load: function() {
			$('#dataGridForOutBound').bootstrapTable('refresh');
		},
	}
})